package com.thirdgroup.service.impl;

import com.thirdgroup.dao.BillingDao;
import com.thirdgroup.dao.BillingOrderDao;
import com.thirdgroup.dao.impl.BillingDaoImpl;
import com.thirdgroup.dao.impl.BillingOrderDaoImpl;
import com.thirdgroup.pojo.entity.OrderInfo;
import com.thirdgroup.pojo.vo.BillingInfoVO;
import com.thirdgroup.pojo.vo.BingVo;
import com.thirdgroup.service.BillingService;
import com.thirdgroup.utils.respond.R;

import java.util.List;

public class BillingServiceImpl implements BillingService {
    private BillingDao billingDao=new BillingDaoImpl();
    private BillingOrderDao billingOrderDao=new BillingOrderDaoImpl();

    @Override
    public R Billing(String customerID) {
        List<BillingInfoVO> billingInfoVOS = billingDao.selectBycustomerID(customerID);
        List<OrderInfo> orderInfos = billingOrderDao.selectBycustomerID(customerID);
        Double aDouble = billingDao.SumBycustomerID(customerID);
        Double aDouble1 = billingOrderDao.SumBycustomerID(customerID);
        double sum = aDouble1 + aDouble;
        BingVo bingVo = new BingVo();
        bingVo.setSum(sum);
        bingVo.setPhoneCard(billingInfoVOS);
        bingVo.setOrder(orderInfos);
        if (bingVo!=null&&!"".equals(bingVo)){
            System.out.println(bingVo);
            return R.ok(bingVo);
        }
        System.out.println("系统繁忙，请稍后再试~");
        return R.error(500,"系统繁忙，请稍后再试~");

    }
}
